package com.dts.gateway.controller;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.gateway.config.GatewayProperties;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


/**
 * （自定义类描述）
 *
 * @author zhoujh
 * @date 2022/06/01 14:23
 */
@RestController
@RequestMapping("test")
@Slf4j
public class TestController {
    @GetMapping
    public String getT(){
        GatewayProperties gatewayProperties = new GatewayProperties();
        log.info("配置:{}", JSON.toJSONString(gatewayProperties));
        log.info("路由配置信息：{}", gatewayProperties.getRoutes());
        return "hello world";
    }
    @GetMapping("/redirect")
    public void redirect(HttpServletResponse response) throws IOException {
        log.info("进入重定向接口......");
        response.sendRedirect("http://192.168.1.118:8443");
    }
}
